package com.znsb.msfq.activity;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.znsb.msfq.BaseActivity;
import com.znsb.msfq.R;
import com.znsb.msfq.adapter.MyPagerSlideTabAdapter;
import com.znsb.msfq.fragment.CommonLoginFragment;
import com.znsb.msfq.fragment.QucikLoginFragment;
import com.znsb.msfq.utils.IntentUtils;
import com.znsb.msfq.view.PagerSlidingTabStrip;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;

/**
 * @name：
 * @author： 孙科技
 * @phone： 13308334117
 * @createTime： 2017/2/9
 * @modifyTime： 2017/2/9
 * @explain：
 */

public class LoginActivity extends BaseActivity {

    @Bind(R.id.bar_img_back)
    ImageView barImgBack;
    @Bind(R.id.bar_tv_title)
    TextView barTvTitle;
    @Bind(R.id.bar_tv_other)
    TextView barTvOther;
    @Bind(R.id.login_tbs)
    PagerSlidingTabStrip loginTbs;
    @Bind(R.id.login_pager)
    ViewPager loginPager;

    @Override
    protected int getlayoutView() {
        return R.layout.act_login;
    }

    @Override
    protected void initView(View view) {
        barTvTitle.setText("登录");
        barTvOther.setVisibility(View.VISIBLE);
        barTvOther.setText("注册");
        initPagers();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void clickListener(View view) {

    }

    @OnClick({R.id.bar_img_back, R.id.bar_tv_other})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bar_img_back:
                finish();
                break;
            case R.id.bar_tv_other:
                IntentUtils.startActivityAnimGeneral(this, RegisterActivity.class, null);
                break;
        }
    }

    private Fragment quickloginFragment, commonLoginFragment;
    private List<Fragment> pages = new ArrayList<Fragment>();

    private void initPagers() {
        ArrayList<String> list = new ArrayList<>();
        list.add("快速登录");
        list.add("普通登录");
        if (quickloginFragment == null) {
            quickloginFragment = new QucikLoginFragment();
        }

        if (commonLoginFragment == null) {
            commonLoginFragment = new CommonLoginFragment();
        }
        pages.add(quickloginFragment);
        pages.add(commonLoginFragment);

        loginPager.setAdapter(new MyPagerSlideTabAdapter(getSupportFragmentManager(), pages, list));
        loginPager.setCurrentItem(0);
        loginTbs.setViewPager(loginPager);
        loginTbs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        loginTbs.setOnPagerTitleItemClickListener(new PagerSlidingTabStrip.OnPagerTitleItemClickListener() {
            @Override
            public void onSingleClickItem(int position) {
            }

            @Override
            public void onDoubleClickItem(int position) {
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }



}
